#include<bits/stdc++.h>
using namespace std;
int t,n,a[200005],b[200005],m;
void c(){
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            if(b[j]==b[i]){
                if(a[j]==a[i]){
                    ans+=a[i];
                }
                break;
            }
        }
    }
    m=max(m,ans);
}
void dfs(int u){
    if(u>n){
        c();
        return ;
    }
    for(int i=0;i<=1;i++){
        b[u]=i;
        dfs(u+1);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        memset(b,0,sizeof(b));
        m=0;
        dfs(1);
        cout<<m;
        if(t!=0){
            cout<<endl;
        }
    }
    fclose(stdin);
    fclose(stdout);
}